<template>
  <div class="continua">
    <div class="content">
      <h3>我是父组件</h3>

      <!--      <Children :info="info">-->
      <!--        <template v-slot="props">-->
      <!--          <p :style="{background:props.suibian.done?'green':'red'}">-->
      <!--            {{ props.$index }}|{{ props.suibian.do }}-->
      <!--          </p>-->
      <!--        </template>-->
      <!--      </Children>-->

      <!--可以通过解构赋值的形式接收数据-->
      <!--      <Children :info="info">-->
      <!--        <template v-slot="{suibian,$index}">-->
      <!--          <p :style="{background:suibian.done?'green':'red'}">-->
      <!--            测试 == {{ $index }}|{{ suibian.do }}-->
      <!--          </p>-->
      <!--        </template>-->
      <!--      </Children>-->

      <!--      <Children :info="info">-->
      <!--        <template v-slot:default="{suibian,$index}">-->
      <!--          <p :style="{background:suibian.done?'green':'red'}">-->
      <!--            {{ $index }}|{{ suibian.do }}-->
      <!--          </p>-->
      <!--        </template>-->
      <!--      </Children>-->

      <!--      <Children :info="info">-->
      <!--        <template #default="{suibian,$index}">-->
      <!--          <p :style="{background:suibian.done?'green':'red'}">-->
      <!--            {{ $index }}|{{ suibian.do }}-->
      <!--          </p>-->
      <!--        </template>-->
      <!--      </Children>-->

      <Children :info="info">
        <template #="{suibian,$index}">
          <p :style="{background:suibian.done?'green':'red'}">
            {{ $index }}|{{ suibian.do }}
          </p>
        </template>
      </Children>

    </div>
  </div>
</template>

<script setup>
import {ref} from "vue";
import Children from "@/components/05组件通讯/07作用域插槽/children.vue";

const info = ref([
  {
    id: 1,
    do: "吃了一个包子！",
    done: true
  }, {
    id: 2,
    do: "扶老太太过马路！",
    done: false
  }
  , {
    id: 3,
    do: "赚了1000万！",
    done: true
  }
]);
</script>

<style scoped lang="less">
.continua {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;

  .content {
    width: 500px;
    height: 500px;
    border: 1px solid #ccc;
  }
}
</style>
